/*
 * @Author: wuqingchun
 * @Date: 2025-01-20 20:16:22
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2025-01-20 20:31:57
 */
#include <iostream>

#include "student.h"
#include "student.pb.h"

void CStudent::Test()
{
    student stu;

    stu.set_id(10);
    stu.set_age(18);
    stu.set_sex("man");
    stu.set_name("test");

    // 序列化对象，最终得到一个字符串
	std::string output;
	// 此时得到的output是二进制数据
	stu.SerializeToString(&output);

    // 反序列化数据
	student ss;
	ss.ParseFromString(output);
	std::cout << "id = " << ss.id() 
			  << ", age = " << ss.age()
			  << ", name = " << ss.name()
			  << ", sex = " << ss.sex()
			  << std::endl;
}